using SM.core;
using SS;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace SM.sys
{
	public class frmAccount : Form
	{
		private IContainer components = null;
		private ListView lsvAccount;
		private ColumnHeader columnHeader1;
		private ColumnHeader columnHeader2;
		private ColumnHeader columnHeader3;
		private Button btnAdd;
		private Button btnEdit;
		private Button btnSave;
		private Button btnDel;
		private Button btnClose;
		private Label label1;
		private TextBox txtFullName;
		private Label label2;
		private TextBox txtUserName;
		private Label label3;
		private TextBox txtPassConfirm;
		private Label label4;
		private TextBox txtPass;
		private ColumnHeader columnHeader4;
		private ColumnHeader columnHeader5;
		private Label label5;
		private CheckBox ckbStatus;
		private ColumnHeader columnHeader6;
		private ComboBox cbbWareHouse;
		private Label label6;
		private GroupBox groupBox1;
		private ColumnHeader columnHeader7;
		private Label label7;
		private CheckBox cbbDoctor;
		private ListView lsvGroup;
		private DataGridView dgvFunctions;
		private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
		private DataGridViewCheckBoxColumn TMP;
		private DataGridViewTextBoxColumn ID;
		private DataGridViewTextBoxColumn Description;
		private Account objAccount = new Account();
		private Group objGroup = new Group();
		private Func objFunc = new Func();
		private int act = 0;
		private string AccountID = "";
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(frmAccount));
			this.ckbStatus = new CheckBox();
			this.label5 = new Label();
			this.lsvGroup = new ListView();
			this.columnHeader4 = new ColumnHeader();
			this.columnHeader5 = new ColumnHeader();
			this.label3 = new Label();
			this.txtPassConfirm = new TextBox();
			this.label4 = new Label();
			this.txtPass = new TextBox();
			this.label2 = new Label();
			this.txtUserName = new TextBox();
			this.label1 = new Label();
			this.txtFullName = new TextBox();
			this.lsvAccount = new ListView();
			this.columnHeader1 = new ColumnHeader();
			this.columnHeader2 = new ColumnHeader();
			this.columnHeader3 = new ColumnHeader();
			this.columnHeader6 = new ColumnHeader();
			this.columnHeader7 = new ColumnHeader();
			this.btnAdd = new Button();
			this.btnEdit = new Button();
			this.btnSave = new Button();
			this.btnDel = new Button();
			this.btnClose = new Button();
			this.cbbWareHouse = new ComboBox();
			this.label6 = new Label();
			this.groupBox1 = new GroupBox();
			this.cbbDoctor = new CheckBox();
			this.label7 = new Label();
			this.dgvFunctions = new DataGridView();
			this.dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
			this.TMP = new DataGridViewCheckBoxColumn();
			this.ID = new DataGridViewTextBoxColumn();
			this.Description = new DataGridViewTextBoxColumn();
			this.groupBox1.SuspendLayout();
			((ISupportInitialize)this.dgvFunctions).BeginInit();
			base.SuspendLayout();
			this.ckbStatus.AutoSize = true;
			this.ckbStatus.BackColor = Color.Transparent;
			this.ckbStatus.Enabled = false;
			this.ckbStatus.Location = new System.Drawing.Point(534, 80);
			this.ckbStatus.Name = "ckbStatus";
			this.ckbStatus.Size = new Size(77, 19);
			this.ckbStatus.TabIndex = 4;
			this.ckbStatus.Text = "Kích hoạt";
			this.ckbStatus.UseVisualStyleBackColor = false;
			this.label5.AutoSize = true;
			this.label5.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label5.Location = new System.Drawing.Point(380, 129);
			this.label5.Name = "label5";
			this.label5.Size = new Size(150, 15);
			this.label5.TabIndex = 9;
			this.label5.Text = "Phân nhóm cho tài khoản";
			this.lsvGroup.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.lsvGroup.CheckBoxes = true;
			this.lsvGroup.Columns.AddRange(new ColumnHeader[]
			{
				this.columnHeader4,
				this.columnHeader5
			});
			this.lsvGroup.Cursor = Cursors.Hand;
			this.lsvGroup.FullRowSelect = true;
			this.lsvGroup.HeaderStyle = ColumnHeaderStyle.None;
			this.lsvGroup.Location = new System.Drawing.Point(383, 147);
			this.lsvGroup.Name = "lsvGroup";
			this.lsvGroup.Size = new Size(280, 314);
			this.lsvGroup.TabIndex = 5;
			this.lsvGroup.UseCompatibleStateImageBehavior = false;
			this.lsvGroup.View = View.Details;
			this.columnHeader4.Text = "Số hiệu";
			this.columnHeader4.Width = 58;
			this.columnHeader5.Text = "Tên nhóm";
			this.columnHeader5.Width = 200;
			this.label3.AutoSize = true;
			this.label3.Location = new System.Drawing.Point(304, 62);
			this.label3.Name = "label3";
			this.label3.Size = new Size(104, 15);
			this.label3.TabIndex = 7;
			this.label3.Text = "Lặp lại mật khẩu :";
			this.txtPassConfirm.BackColor = Color.White;
			this.txtPassConfirm.Enabled = false;
			this.txtPassConfirm.Location = new System.Drawing.Point(412, 59);
			this.txtPassConfirm.Name = "txtPassConfirm";
			this.txtPassConfirm.PasswordChar = '*';
			this.txtPassConfirm.Size = new Size(203, 21);
			this.txtPassConfirm.TabIndex = 3;
			this.label4.AutoSize = true;
			this.label4.Location = new System.Drawing.Point(22, 61);
			this.label4.Name = "label4";
			this.label4.Size = new Size(62, 15);
			this.label4.TabIndex = 5;
			this.label4.Text = "Mật khẩu :";
			this.txtPass.BackColor = Color.White;
			this.txtPass.Enabled = false;
			this.txtPass.Location = new System.Drawing.Point(87, 59);
			this.txtPass.Name = "txtPass";
			this.txtPass.PasswordChar = '*';
			this.txtPass.Size = new Size(189, 21);
			this.txtPass.TabIndex = 2;
			this.label2.AutoSize = true;
			this.label2.Location = new System.Drawing.Point(279, 35);
			this.label2.Name = "label2";
			this.label2.Size = new Size(129, 15);
			this.label2.TabIndex = 3;
			this.label2.Text = "Tài khoản đăng nhập :";
			this.txtUserName.BackColor = Color.White;
			this.txtUserName.Enabled = false;
			this.txtUserName.Location = new System.Drawing.Point(412, 32);
			this.txtUserName.Name = "txtUserName";
			this.txtUserName.Size = new Size(203, 21);
			this.txtUserName.TabIndex = 1;
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(30, 34);
			this.label1.Name = "label1";
			this.label1.Size = new Size(54, 15);
			this.label1.TabIndex = 1;
			this.label1.Text = "Tên gọi :";
			this.txtFullName.BackColor = Color.White;
			this.txtFullName.Enabled = false;
			this.txtFullName.Location = new System.Drawing.Point(87, 32);
			this.txtFullName.Name = "txtFullName";
			this.txtFullName.Size = new Size(189, 21);
			this.txtFullName.TabIndex = 0;
			this.lsvAccount.Activation = ItemActivation.OneClick;
			this.lsvAccount.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left);
			this.lsvAccount.Columns.AddRange(new ColumnHeader[]
			{
				this.columnHeader1,
				this.columnHeader2,
				this.columnHeader3,
				this.columnHeader6,
				this.columnHeader7
			});
			this.lsvAccount.Cursor = Cursors.Hand;
			this.lsvAccount.FullRowSelect = true;
			this.lsvAccount.HeaderStyle = ColumnHeaderStyle.Nonclickable;
			this.lsvAccount.Location = new System.Drawing.Point(5, 147);
			this.lsvAccount.Name = "lsvAccount";
			this.lsvAccount.Size = new Size(373, 314);
			this.lsvAccount.TabIndex = 11;
			this.lsvAccount.UseCompatibleStateImageBehavior = false;
			this.lsvAccount.View = View.Details;
			this.lsvAccount.SelectedIndexChanged += new EventHandler(this.lsvAccount_SelectedIndexChanged);
			this.columnHeader1.Text = "STT";
			this.columnHeader1.Width = 0;
			this.columnHeader2.Text = "Tài khoản";
			this.columnHeader2.Width = 130;
			this.columnHeader3.Text = "Tên gọi";
			this.columnHeader3.Width = 223;
			this.columnHeader6.Width = 0;
			this.columnHeader7.Width = 0;
			this.btnAdd.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnAdd.BackColor = Color.FromArgb(192, 255, 255);
			this.btnAdd.FlatStyle = FlatStyle.System;
			this.btnAdd.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnAdd.Location = new System.Drawing.Point(6, 467);
			this.btnAdd.Name = "btnAdd";
			this.btnAdd.Size = new Size(75, 28);
			this.btnAdd.TabIndex = 6;
			this.btnAdd.Text = "&Thêm mới";
			this.btnAdd.UseVisualStyleBackColor = false;
			this.btnAdd.Click += new EventHandler(this.btnAdd_Click);
			this.btnEdit.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnEdit.BackColor = Color.FromArgb(192, 255, 255);
			this.btnEdit.Enabled = false;
			this.btnEdit.FlatStyle = FlatStyle.System;
			this.btnEdit.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnEdit.Location = new System.Drawing.Point(82, 467);
			this.btnEdit.Name = "btnEdit";
			this.btnEdit.Size = new Size(75, 28);
			this.btnEdit.TabIndex = 7;
			this.btnEdit.Text = "&Sửa đổi";
			this.btnEdit.UseVisualStyleBackColor = false;
			this.btnEdit.Click += new EventHandler(this.btnEdit_Click);
			this.btnSave.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnSave.BackColor = Color.FromArgb(192, 255, 255);
			this.btnSave.Enabled = false;
			this.btnSave.FlatStyle = FlatStyle.System;
			this.btnSave.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnSave.Location = new System.Drawing.Point(158, 467);
			this.btnSave.Name = "btnSave";
			this.btnSave.Size = new Size(75, 28);
			this.btnSave.TabIndex = 8;
			this.btnSave.Text = "&Ghi nhận";
			this.btnSave.UseVisualStyleBackColor = false;
			this.btnSave.Click += new EventHandler(this.btnSave_Click);
			this.btnDel.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left);
			this.btnDel.BackColor = Color.FromArgb(192, 255, 255);
			this.btnDel.Enabled = false;
			this.btnDel.FlatStyle = FlatStyle.System;
			this.btnDel.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
			this.btnDel.Location = new System.Drawing.Point(234, 467);
			this.btnDel.Name = "btnDel";
			this.btnDel.Size = new Size(75, 28);
			this.btnDel.TabIndex = 9;
			this.btnDel.Text = "&Xoá bỏ";
			this.btnDel.UseVisualStyleBackColor = false;
			this.btnDel.Click += new EventHandler(this.btnDel_Click);
			this.btnClose.Anchor = (AnchorStyles.Bottom | AnchorStyles.Right);
			this.btnClose.BackColor = SystemColors.ButtonFace;
			this.btnClose.FlatStyle = FlatStyle.System;
			this.btnClose.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 163);
            ////this.btnClose.Image = (Image)componentResourceManager.GetObject("btnClose.Image");
			//this.btnClose.ImageAlign = ContentAlignment.MiddleLeft;
			this.btnClose.Location = new System.Drawing.Point(795, 467);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new Size(100, 28);
			this.btnClose.TabIndex = 10;
			this.btnClose.Text = "Thoát  [ESC]";
			this.btnClose.UseVisualStyleBackColor = false;
			this.btnClose.Click += new EventHandler(this.btnClose_Click);
			this.cbbWareHouse.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbbWareHouse.FormattingEnabled = true;
			this.cbbWareHouse.Location = new System.Drawing.Point(83, 77);
			this.cbbWareHouse.Name = "cbbWareHouse";
			this.cbbWareHouse.Size = new Size(189, 23);
			this.cbbWareHouse.TabIndex = 10;
			this.label6.AutoSize = true;
			this.label6.Location = new System.Drawing.Point(13, 81);
			this.label6.Name = "label6";
			this.label6.Size = new Size(66, 15);
			this.label6.TabIndex = 11;
			this.label6.Text = "Kho hàng :";
			this.groupBox1.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.groupBox1.Controls.Add(this.cbbDoctor);
			this.groupBox1.Controls.Add(this.ckbStatus);
			this.groupBox1.Controls.Add(this.cbbWareHouse);
			this.groupBox1.Controls.Add(this.label6);
			this.groupBox1.Location = new System.Drawing.Point(4, 8);
			this.groupBox1.Name = "groupBox1";
			this.groupBox1.Size = new Size(891, 110);
			this.groupBox1.TabIndex = 12;
			this.groupBox1.TabStop = false;
			this.groupBox1.Text = "Thông tin về tài khoản";
			this.cbbDoctor.AutoSize = true;
			this.cbbDoctor.BackColor = Color.Transparent;
			this.cbbDoctor.Enabled = false;
			this.cbbDoctor.Location = new System.Drawing.Point(303, 80);
			this.cbbDoctor.Name = "cbbDoctor";
			this.cbbDoctor.Size = new Size(191, 19);
			this.cbbDoctor.TabIndex = 12;
			this.cbbDoctor.Text = "Tài khoản Bác sĩ kê đơn thuốc";
			this.cbbDoctor.UseVisualStyleBackColor = false;
			this.label7.AutoSize = true;
			this.label7.Font = new Font("Arial", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
			this.label7.Location = new System.Drawing.Point(4, 129);
			this.label7.Name = "label7";
			this.label7.Size = new Size(122, 15);
			this.label7.TabIndex = 13;
			this.label7.Text = "Danh sách tài khoản";
			this.dgvFunctions.AllowUserToAddRows = false;
			this.dgvFunctions.AllowUserToDeleteRows = false;
			this.dgvFunctions.AllowUserToResizeColumns = false;
			this.dgvFunctions.AllowUserToResizeRows = false;
			this.dgvFunctions.Anchor = (AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right);
			this.dgvFunctions.BackgroundColor = Color.White;
			this.dgvFunctions.BorderStyle = BorderStyle.Fixed3D;
			this.dgvFunctions.ColumnHeadersHeight = 26;
			this.dgvFunctions.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
			this.dgvFunctions.Columns.AddRange(new DataGridViewColumn[]
			{
				this.TMP,
				this.ID,
				this.Description
			});
			this.dgvFunctions.EnableHeadersVisualStyles = false;
			this.dgvFunctions.Location = new System.Drawing.Point(669, 147);
			this.dgvFunctions.Name = "dgvFunctions";
			this.dgvFunctions.RowHeadersVisible = false;
			this.dgvFunctions.Size = new Size(226, 314);
			this.dgvFunctions.TabIndex = 14;
			this.dataGridViewTextBoxColumn1.DataPropertyName = "ID";
			this.dataGridViewTextBoxColumn1.HeaderText = "ID";
			this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
			this.dataGridViewTextBoxColumn1.Visible = false;
			this.TMP.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			this.TMP.DataPropertyName = "TMP";
			this.TMP.HeaderText = " -:-";
			this.TMP.MinimumWidth = 30;
			this.TMP.Name = "TMP";
			this.TMP.Width = 30;
			this.ID.DataPropertyName = "ID";
			this.ID.HeaderText = "ID";
			this.ID.Name = "ID";
			this.ID.Visible = false;
			this.Description.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
			this.Description.DataPropertyName = "Description";
			this.Description.HeaderText = "Thao tác";
			this.Description.Name = "Description";
			this.Description.Resizable = DataGridViewTriState.True;
			this.Description.SortMode = DataGridViewColumnSortMode.NotSortable;
			base.AutoScaleDimensions = new SizeF(7f, 15f);
			//base.AutoScaleMode = AutoScaleMode.Font;
			base.ClientSize = new Size(900, 500);
			base.Controls.Add(this.dgvFunctions);
			base.Controls.Add(this.label7);
			base.Controls.Add(this.label3);
			base.Controls.Add(this.btnClose);
			base.Controls.Add(this.btnDel);
			base.Controls.Add(this.label5);
			base.Controls.Add(this.btnSave);
			base.Controls.Add(this.lsvGroup);
			base.Controls.Add(this.btnEdit);
			base.Controls.Add(this.btnAdd);
			base.Controls.Add(this.txtPassConfirm);
			base.Controls.Add(this.label4);
			base.Controls.Add(this.txtPass);
			base.Controls.Add(this.txtFullName);
			base.Controls.Add(this.label2);
			base.Controls.Add(this.label1);
			base.Controls.Add(this.txtUserName);
			base.Controls.Add(this.groupBox1);
			base.Controls.Add(this.lsvAccount);
			this.Cursor = Cursors.Hand;
			this.Font = new Font("Arial", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
			//base.Icon = (System.Drawing.Icon)componentResourceManager.GetObject("$this.Icon");
            ////base.Icon = (Icon)componentResourceManager.GetObject("$this.Icon");
			base.KeyPreview = true;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "frmAccount";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = " .: Tài khoản người dùng";
			base.Load += new EventHandler(this.frmAccount_Load);
			base.SizeChanged += new EventHandler(this.frmAccount_SizeChanged);
			base.KeyDown += new KeyEventHandler(this.frmAccount_KeyDown);
			this.groupBox1.ResumeLayout(false);
			this.groupBox1.PerformLayout();
			((ISupportInitialize)this.dgvFunctions).EndInit();
			base.ResumeLayout(false);
			base.PerformLayout();
		}
		public frmAccount()
		{
			this.InitializeComponent();
		}
		private void frmAccount_Load(object sender, EventArgs e)
		{
			this.objFunc.LoadComboBox("SELECT * FROM [TabWareHouse] ORDER BY [WareHouse_ID]", this.cbbWareHouse, "WareHouse_ID", "WareHouse_Name");
			this.objAccount.getPerExtention(this.dgvFunctions);
			this.objGroup.loadToListView(this.lsvGroup);
			this.objAccount.loadToListView(this.lsvAccount);
			if (this.cbbWareHouse.Items.Count > 0)
			{
				this.cbbWareHouse.SelectedIndex = 0;
			}
		}
		private void btnClose_Click(object sender, EventArgs e)
		{
			base.Close();
		}
		private void btnAdd_Click(object sender, EventArgs e)
		{
			this.act = 0;
			this.txtFullName.Enabled = true;
			this.txtUserName.Enabled = true;
			this.txtPass.Enabled = true;
			this.txtPassConfirm.Enabled = true;
			this.ckbStatus.Enabled = true;
			this.txtFullName.Text = "";
			this.txtUserName.Text = "";
			this.txtPass.Text = "";
			this.AccountID = "";
			this.txtPassConfirm.Text = "";
			this.ckbStatus.Checked = false;
			this.txtFullName.Focus();
			this.btnEdit.Enabled = false;
			this.btnDel.Enabled = false;
			this.btnSave.Enabled = true;
		}
		private void lsvAccount_SelectedIndexChanged(object sender, EventArgs e)
		{
			try
			{
				this.txtUserName.Text = this.lsvAccount.Items[this.lsvAccount.FocusedItem.Index].SubItems[1].Text;
				this.AccountID = this.lsvAccount.Items[this.lsvAccount.FocusedItem.Index].SubItems[1].Text;
				this.txtFullName.Text = this.lsvAccount.Items[this.lsvAccount.FocusedItem.Index].SubItems[2].Text;
				this.cbbWareHouse.SelectedValue = this.lsvAccount.Items[this.lsvAccount.FocusedItem.Index].SubItems[4].Text;
				if (this.lsvAccount.Items[this.lsvAccount.FocusedItem.Index].SubItems[3].Text == "1")
				{
					this.ckbStatus.Checked = true;
				}
				else
				{
					this.ckbStatus.Checked = false;
				}
				this.objAccount.checkGroup(this.txtUserName.Text, this.lsvGroup);
				if (this.objAccount.checkDoctorAcc(this.txtUserName.Text) != "-:-")
				{
					this.cbbDoctor.Checked = true;
				}
				else
				{
					this.cbbDoctor.Checked = false;
				}
				for (int i = 0; i < this.dgvFunctions.RowCount; i++)
				{
					if (this.objAccount.checkPerExtention(this.txtUserName.Text, this.dgvFunctions.Rows[i].Cells["ID"].Value.ToString()))
					{
						this.dgvFunctions.Rows[i].Cells["TMP"].Value = "True";
					}
					else
					{
						this.dgvFunctions.Rows[i].Cells["TMP"].Value = "False";
					}
				}
				this.btnEdit.Enabled = true;
				this.btnDel.Enabled = true;
				this.txtFullName.Enabled = false;
				this.txtUserName.Enabled = false;
				this.txtPass.Enabled = false;
				this.txtPassConfirm.Enabled = false;
				this.ckbStatus.Enabled = false;
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
		}
		private void btnEdit_Click(object sender, EventArgs e)
		{
			this.act = 1;
			this.AccountID = this.txtUserName.Text;
			this.txtFullName.Enabled = true;
			this.txtUserName.Enabled = true;
			this.txtPass.Enabled = true;
			this.txtPassConfirm.Enabled = true;
			this.txtFullName.Focus();
			this.btnDel.Enabled = false;
			this.btnSave.Enabled = true;
			this.ckbStatus.Enabled = true;
			this.cbbDoctor.Enabled = true;
		}
		private void btnSave_Click(object sender, EventArgs e)
		{
			if (this.txtFullName.Text == "")
			{
				MessageBox.Show("Nhập vào tên gọi của tài khoản!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
				this.txtFullName.Focus();
			}
			else
			{
				if (this.txtUserName.Text == "")
				{
					MessageBox.Show("Nhập vào tên hợp lệ của tài khoản!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					this.txtUserName.Focus();
				}
				else
				{
					if (this.act == 0)
					{
						if (this.objAccount.checkUser(this.txtUserName.Text))
						{
							MessageBox.Show("Tài khoản \"" + this.txtUserName.Text + "\" đã tồn tại trong hệ thống !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
							this.txtUserName.Focus();
							return;
						}
					}
					if (this.txtPass.Text != "")
					{
						if (this.txtPass.Text != this.txtPassConfirm.Text)
						{
							MessageBox.Show("Hãy chắc chắn về mật khẩu đã nhập vào!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
							this.txtPassConfirm.Focus();
							return;
						}
					}
					int status;
					if (this.ckbStatus.Checked)
					{
						status = 1;
					}
					else
					{
						status = 0;
					}
					string text = "";
					for (int i = 0; i < this.lsvGroup.Items.Count; i++)
					{
						if (this.lsvGroup.Items[i].Checked)
						{
							text = text + "\"" + this.lsvGroup.Items[i].SubItems[0].Text + "\",";
						}
					}
					if (text != "")
					{
						text = text.Remove(text.Length - 1);
					}
					if (this.objAccount.action11(this.AccountID, this.txtUserName.Text, this.txtFullName.Text, this.txtPass.Text, status, text, this.cbbWareHouse.SelectedValue.ToString()) == 0)
					{
						this.objAccount.delExtPermission(this.txtUserName.Text);
						for (int i = 0; i < this.dgvFunctions.RowCount; i++)
						{
							if (this.dgvFunctions.Rows[i].Cells["TMP"].Value.ToString() == "True")
							{
								this.objAccount.setExtPermission(this.txtUserName.Text, this.dgvFunctions.Rows[i].Cells["ID"].Value.ToString());
							}
						}
						this.btnEdit.Enabled = true;
						this.btnDel.Enabled = true;
						this.txtFullName.Enabled = false;
						this.txtUserName.Enabled = false;
						this.txtPass.Enabled = false;
						this.txtPassConfirm.Enabled = false;
						this.ckbStatus.Enabled = false;
						this.btnSave.Enabled = false;
						this.cbbDoctor.Enabled = false;
						this.objAccount.loadToListView(this.lsvAccount);
					}
					else
					{
						MessageBox.Show("Có lỗi xảy ra trong quá trình lưu thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					}
				}
			}
		}
		private void btnDel_Click(object sender, EventArgs e)
		{
			if (this.txtUserName.Text != "")
			{
				if (MessageBox.Show("Bạn có thật sự muốn xoá tài khoản được chọn không!", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
				{
					string a = this.objAccount.CheckEmpExitstInOutBill(this.txtUserName.Text) + this.objAccount.CheckEmpExitstInBill(this.txtUserName.Text);
					if (a != "")
					{
						MessageBox.Show("Tài khoản này đã có vai trò ở phiếu thu,chi hoặc xuất nhập!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					}
					else
					{
						if (this.objAccount.delItem(this.txtUserName.Text) == 0)
						{
							this.AccountID = "";
							this.btnDel.Enabled = true;
							this.txtFullName.Enabled = false;
							this.txtUserName.Enabled = false;
							this.txtPass.Enabled = false;
							this.txtPassConfirm.Enabled = false;
							this.ckbStatus.Enabled = false;
							this.btnSave.Enabled = false;
							this.objAccount.loadToListView(this.lsvAccount);
						}
					}
				}
			}
			else
			{
				MessageBox.Show("Bạn chưa chọn tài khoản cần xoá!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
			}
		}
		private void frmAccount_KeyDown(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Escape)
			{
				base.Close();
			}
		}
		private void frmAccount_SizeChanged(object sender, EventArgs e)
		{
		}
	}
}
